var videos = new Array
var oldVideos = new Array
var curVideoIdx

function arraysIdentical(a, b) {
    var i = a.length;
    if (i != b.length) return false;
    while (i--) {
        if (a[i] !== b[i]) return false;
    }
    return true;
};

function run()
{
    var videos = tools.ls(videosFolderPath, false, false)
    for (var i = 0; i < excludeVideos.length; ++i)
        videos.splice(excludeVideos[i], 1)
    console.log(videos)

    if (!arraysIdentical(videos, oldVideos)) {
        curVideoIdx = 0;
        oldVideos = videos
        player.source = videos[curVideoIdx];
        console.log("RUN AGAIN")
    }

    if (videos.length <= 0) {
        console.log("no videos!!!")
        //showEmptyWarning()
        return;
    }


    player.play()
}

function stop()
{
    player.pause()
}

function stopped()
{
    if (!running) return;
    if (++curVideoIdx >= videos.length)
        curVideoIdx = 0;
    player.source = videos[curVideoIdx];
    player.play();
    console.log(videos[curVideoIdx]);
}
